<%@ Page Language="VB" StylesheetTheme="Default"  MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="CategoryManager.aspx.vb" Inherits="Modules_Questionnaires_CategoryManager" title="Questionnaire Category Manager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <div>
        <table id="Table1" border="0" cellpadding="2" cellspacing="2" width="100%">
            <tr>
                <td colspan="3">
                    <strong><font size="2">CATEGORY MANAGER</font></strong></td>
                <td align="right" colspan="1">
                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Secure/QuestionnaireManagement/Default.aspx" ForeColor="Blue">Back</asp:HyperLink></td>
            </tr>
            <tr style="color: #000000">
                <td colspan="4">
                    <hr size="1" width="100%" />
                </td>
            </tr>
            <tr style="color: #000000">
                <td rowspan="3" valign="top" width="15">
                    &nbsp;</td>
                <td colspan="3">
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" height="1">
                    <asp:LinkButton ID="lbutNew" runat="server" Font-Bold="True"><SPAN style="POSITION: relative; TOP: -4px; left:-4px">Add A New Category</SPAN><img src="../../Images/new.gif" style="border-width:0px;POSITION: relative;" /></asp:LinkButton></td>
                <td colspan="2" valign="top" width="300">
                </td>
            </tr>
            <tr>
                <td valign="top" style="height: 342px">
                    <asp:GridView ID="gvCategories" runat="server" DataSourceID="CategoryODS" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Width="820px">
                        <Columns>
                            <asp:TemplateField HeaderText="Category" SortExpression="Name">
                                <EditItemTemplate>
                                    <asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Bind("ID") %>'/>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Name") %>'  Width="92%"/><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Category Name can not be blank." ControlToValidate="TextBox1">*</asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:TextBox ID="txtName" Width="92%" runat="server" /><asp:RequiredFieldValidator
                                        ID="reqAdd" runat="server" ControlToValidate="txtName" ErrorMessage="Category Name can not be blank.">*</asp:RequiredFieldValidator>
                                </FooterTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>'/>
                                </ItemTemplate>
                                <ItemStyle Width="200px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Description" SortExpression="Description">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>' Width="98%"></asp:TextBox>
                                </EditItemTemplate>
                                <ItemStyle Width="520px" />
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                                </ItemTemplate>
                                <FooterTemplate>
                                    <asp:TextBox ID="txtDesc" Width="98%" runat="server" />
                                </FooterTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="# of Questions" SortExpression="NumberOfQuestions">
                                <EditItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("NumberOfQuestions") %>'></asp:Label>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="70px" />
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("NumberOfQuestions") %>'></asp:Label>
                                </ItemTemplate>
                                <FooterTemplate>
                                    <asp:ImageButton ID="butInsert" runat="server" CausesValidation=true OnClick="butInsert_Click" 
                                         AlternateText="Insert" ImageUrl="~/images/ok.gif" />
                                    <asp:ImageButton ID="butCancel" runat="server" CausesValidation=false OnClick="butCancel_Click" 
                                         AlternateText="Cancel" ImageUrl="~/images/cancel.gif" />
                                </FooterTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField ShowHeader="False">
                                <EditItemTemplate>
                                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation=true CommandName="Update" 
                                         AlternateText="Update" ImageUrl="~/images/ok.gif"/>
                                    <asp:ImageButton ID="ImageButton2" runat="server" CausesValidation=false CommandName="Cancel" 
                                         AlternateText="Cancel" ImageUrl="~/images/cancel.gif"/>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:ImageButton ID="ImageButton1" runat="server" CausesValidation=false CommandName="Edit" 
                                         AlternateText="Edit" ImageUrl="~/images/Edit.gif"/>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" Wrap="False" />
                            </asp:TemplateField>
                            
                        </Columns>
                        <EmptyDataTemplate>
                             <table border="0" cellpadding="2" cellspacing="2"
                                style="BORDER-TOP-WIDTH:1px;BORDER-LEFT-WIDTH:1px;BORDER-LEFT-COLOR:black;LEFT:0px;BORDER-BOTTOM-WIDTH:1px;
                                BORDER-BOTTOM-COLOR:black;MARGIN:-4px;WIDTH:820px;BORDER-TOP-COLOR: black;TOP:0px;BACKGROUND-COLOR:white;
                                BORDER-RIGHT-WIDTH:1px;BORDER-RIGHT-COLOR: black">
                                <tr style="font-weight: bold; color: mistyrose; background-color: #4a3c8c">
                                    <th scope="col">Category</th>
                                    <th scope="col">Description</th>
                                    <th scope="col"># of Questions</th>
                                    <th scope="col">&nbsp;</th>
                                </tr>
                                <tr id="trEmptyMessage" runat="server" visible="true" style="color:Black;background-color:#EEEEEE;">
			                        <td colspan=4 align=center >
			                            <br /><strong>There is no category in the database.</strong><br /><br />
			                        </td>
		                        </tr>
                                <tr id="trEmpty" runat="server" visible="false" style="color: black; background-color: #eeeeee">
                                    <td style="width: 200px">
                                        <asp:TextBox ID="txtName" Width="92%" runat="server" /><asp:RequiredFieldValidator
                                            ID="reqAdd" runat="server" ControlToValidate="txtName" ErrorMessage="Category Name can not be blank.">*</asp:RequiredFieldValidator>
                                    </td>
                                    <td style="width: 520px">
                                        <asp:TextBox ID="txtDesc" Width="98%" runat="server" />
                                    </td>
                                    <td style="width: 70px">
                                        <asp:ImageButton ID="butInsert" runat="server" CausesValidation=true OnClick="butInsert_Click" 
                                             AlternateText="Insert" ImageUrl="~/images/ok.gif" />
                                        <asp:ImageButton ID="butCancel" runat="server" CausesValidation=false OnClick="butCancel_Click" 
                                             AlternateText="Cancel" ImageUrl="~/images/cancel.gif" />
                                    </td>
                                    <td align="middle" style="width: 30px; white-space: nowrap" valign="center">
                                        &nbsp;</td>
                                </tr>
                            </table>
                        </EmptyDataTemplate>
                    </asp:GridView>
                    <asp:ObjectDataSource ID="CategoryODS" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetCategories" TypeName="DotNetPM.Business.Questionnaire.CategoryODS" DeleteMethod="DeleteCategory" InsertMethod="CreateCategory" UpdateMethod="UpdateCategory">
                        <DeleteParameters>
                            <asp:Parameter Name="original_ID" Type="Int32" />
                            <asp:Parameter Name="original_Name" Type="String" />
                        </DeleteParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="id" Type="Int32" />
                            <asp:Parameter Name="name" Type="String" />
                            <asp:Parameter Name="description" Type="String" />
                        </UpdateParameters>
                        <InsertParameters>
                            <asp:Parameter Name="name" Type="String" />
                            <asp:Parameter Name="desc" Type="String" />
                        </InsertParameters>
                    </asp:ObjectDataSource>
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                    </td>
                <td colspan="2" valign="top" style="height: 342px">
                    &nbsp;
                </td>
            </tr>
        </table>
    
    </div>
</asp:Content>

